import request from "@/utils/request";
import { Article } from "./type";

export const getArticleListByTagId = (communityId: string, tagId: string) => {
    return request.get("/community/article/list/tag", {
        params: {
            "communityId": communityId,
            "tagId": tagId
        }
    })
}

export const getArticleList = (communityId: string) => {
    return request.get(`/community/article/list/info`, {
        params: {
            communityId
        }
    });
}

export const getArticleDetail = (articleId: string) => {
    return request.get(`/community/article/info`, {
        params: {
            articleId
        }
    });
}

export const publishArticle = (article: Article) => {
    return request.post("/community/article/publish", article)
}

export const deleteArticle = (articleId: string) => {
    return request.delete(`/community/article/delete`, {
        params: {
            articleId
        }
    });
}

export const likeArticle = (articleId: string) => {
    return request.post(`/community/article/like/publish`, null, {
        params: {
            articleId
        }
    });
}

export const cancelLikeArticle = (articleId: string) => {
    return request.post(`/community/article/like/cancel`, null, {
        params: {
            articleId
        }
    });
}
